import { request } from '@umijs/max';

export async function getArticlePage(
  params: {
    // query
    /** 当前的页码 */
    page?: number;
    /** 页面的容量 */
    size?: number;
  },
  options?: { [key: string]: any },
) {
  return request<{
    code?: number;
    msg?: string;
    data?: Record<string, any>;
  }>('/order', {
    method: 'get',
    params,
    ...(options || {}),
  });
}

export async function updateArticle(data: { [key: string]: any }, options?: { [key: string]: any }) {
  return request<{
    code?: number;
    msg?: string;
    data?: Record<string, any>;
  }>('/order/status', {
    data,
    method: 'put',
    ...(options || {}),
  });
}

export async function addArticle(data: { [key: string]: any }, options?: { [key: string]: any }) {
  return request<{
    code?: number;
    msg?: string;
    data?: Record<string, any>;
  }>('/order', {
    data,
    method: 'POST',
    ...(options || {}),
  });
}

export async function batchDelArticle(data: { idList: number[] }, options?: { [key: string]: any }) {
  return request<{
    code?: number;
    msg?: string;
    data?: Record<string, any>;
  }>('/order', {
    data,
    method: 'delete',
    ...(options || {}),
  });
}
